//
//  SNKPrettyGirlData.m
//  SleepNews
//
//  Created by Kavee DJ on 2017/2/20.
//  Copyright © 2017年 Kavee DJ. All rights reserved.
//

#import "SNKPrettyGirlData.h"

@implementation SNKPrettyGirlData

- (CGFloat)cellHeight
{
    // 如果已经计算过，就直接返回
    if (_cellHeight) return _cellHeight;
    
    _cellHeight += 20; // 上下两个间距
    
    // 文字的高度
    CGSize textMaxSize = CGSizeMake(SCREENW - 2 * 10, MAXFLOAT);
    _cellHeight += [self.title boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
    
    // 中间的内容
    NSArray *array = [self.pixel componentsSeparatedByString:@"*"];
    
    CGFloat middleW = SCREENW;
    CGFloat middleH = middleW * [array.lastObject floatValue] / [array.firstObject floatValue];
    
    CGFloat middleY = _cellHeight;
    CGFloat middleX = 0;
    self.middleFrame = CGRectMake(middleX, middleY, middleW, middleH);
    _cellHeight += middleH + 10 + 30;
    
    return _cellHeight;
}

@end
